/**
 * 
 */
package com.thor.palmmall.rest.sales.input.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.chart.ASalesReportData;
import com.thor.palmmall.spi.chart.SSalesReportData;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class ASalesTotalReportConverter implements Converter<SSalesReportData, ASalesReportData> {

  public static ASalesTotalReportConverter getInstance() {
    if (instance == null)
      instance = new ASalesTotalReportConverter();
    return instance;
  }

  private static ASalesTotalReportConverter instance;

  private ASalesTotalReportConverter() {
  }

  @Override
  public ASalesReportData convert(SSalesReportData source) {
    if (source == null) {
      return null;
    }
    ASalesReportData target = new ASalesReportData();
    target.setArea(source.getArea());
    target.setContract(UCN.newInstance(source.getContract()));
    target.setPermArea(source.getPermArea());
    target.setRange(source.getRange());
    target.setSalesCount(source.getSalesCount());
    target.setSalesTotal(source.getSalesTotal());
    return target;
  }

}
